home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 6.8 KB | 305 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWGrUtil.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWDFAULT_H
- #include "FWDfault.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _SHAPE_
- #include <Shape.h>
- #endif
-
- #ifndef _TRNSFORM_
- #include <Trnsform.h>
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(mathRoutinesIncludes)
- #include <math routines.h>
- #endif
-
- //==============================================================================
- // •• RunTime Info
- //==============================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- //==============================================================================
- // •• Global Methods
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ::InitGraphic
- //------------------------------------------------------------------------------
-
- void InitGraphic()
- {
- #ifdef FW_BUILD_MAC
- Rect rBounds;
- ::SetRect(&rBounds, 0, 0, 10 , 10);
- gGraphicGlobales.gScratchWindow = ::NewCWindow(NULL,
- &rBounds,
- "\p",
- FALSE,
- documentProc,
- NULL,
- FALSE,
- 0);
- #endif
- }
-
- //------------------------------------------------------------------------------
- // ::InsetXMPShape
- //------------------------------------------------------------------------------
-
- void InsetXMPShape(XMPShape *shape, short xInset, short yInset)
- {
- // [HLX] needs to implement GX
- if (shape->IsRectangular())
- {
- FW_CRect rect;
- shape->GetBoundingBox(&rect);
- rect.Inset(ff(xInset), ff(yInset));
- shape->SetRectangle(&rect);
- }
- else
- {
- FW_PlatformRegion shapeRgn = shape->GetQDRegion();
- ::InsetRgn(shapeRgn, xInset, yInset);
- shape->SetQDRegion(shapeRgn);
- }
- }
-
- //------------------------------------------------------------------------------
- // ::GetXMPShapeQDBox
- //------------------------------------------------------------------------------
-
- void GetXMPShapeQDBox(XMPShape *shape, FW_SPlatformRect& rect)
- {
- FW_CRect box;
- shape->GetBoundingBox(&box);
- rect = box;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPShape
- //------------------------------------------------------------------------------
-
- XMPShape* NewXMPShape(const FW_SPlatformRect& rect)
- {
- return NewXMPShape(FW_CRect(rect));
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPShape
- //------------------------------------------------------------------------------
-
- XMPShape* NewXMPShape(const FW_CRect& rect)
- {
- XMPShape *shape = NULL;
- FW_VOLATILE(shape);
-
- TRY
- shape = new XMPShape;
- FailNULL(shape, kXMPErrOutOfMemory);
- FW_CRect notConst(rect);
- shape->SetRectangle(¬Const);
-
- CATCH_ALL
-
- if (shape!=NULL)
- delete shape;
-
- RERAISE;
-
- ENDTRY
-
- return shape;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPShape
- //------------------------------------------------------------------------------
-
- XMPShape* NewXMPShape(FW_PlatformRegion rgn)
- {
- XMPShape *shape = NULL;
- FW_VOLATILE(shape);
-
- TRY
- shape = new XMPShape;
- FailNULL(shape, kXMPErrOutOfMemory);
- shape->SetPlatformShape(kXMPQuickDraw, rgn);
-
- CATCH_ALL
-
- if (shape!=NULL)
- delete shape;
-
- RERAISE;
-
- ENDTRY
-
- return shape;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPShape
- //------------------------------------------------------------------------------
-
- XMPShape* NewXMPShape()
- {
- XMPShape *shape = new XMPShape;
- FailNULL(shape, kXMPErrOutOfMemory);
-
- FW_CRect rect(0,0,0,0);
- shape->SetRectangle(&rect);
-
- return shape;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPShape
- //------------------------------------------------------------------------------
-
- XMPShape* NewXMPShape(XMPShape* otherShape)
- {
- XMPShape *shape = NULL;
- FW_VOLATILE(shape);
-
- TRY
- shape = new XMPShape;
- FailNULL(shape, kXMPErrOutOfMemory);
- shape->CopyFrom(otherShape);
-
- CATCH_ALL
-
- if (shape!=NULL)
- delete shape;
-
- RERAISE;
-
- ENDTRY
-
- return shape;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPTransform
- //------------------------------------------------------------------------------
-
- XMPTransform* NewXMPTransform()
- {
- XMPTransform *transform = new XMPTransform;
- FailNULL(transform, kXMPErrOutOfMemory);
-
- return transform;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPTransform
- //------------------------------------------------------------------------------
-
- XMPTransform* NewXMPTransform(XMPTransform* otherTransform)
- {
- XMPTransform *transform = NULL;
- FW_VOLATILE(transform);
-
- TRY
- transform = new XMPTransform;
- FailNULL(transform, kXMPErrOutOfMemory);
- transform->CopyFrom(otherTransform);
-
- CATCH_ALL
-
- if (transform!=NULL)
- delete transform;
-
- RERAISE;
-
- ENDTRY
-
- return transform;
- }
-
- //------------------------------------------------------------------------------
- // ::NewXMPTransform
- //------------------------------------------------------------------------------
-
- XMPTransform* NewXMPTransform(const FW_CPoint& offset)
- {
- XMPTransform *transform = NULL;
- FW_VOLATILE(transform);
-
- TRY
- transform = new XMPTransform;
- FailNULL(transform, kXMPErrOutOfMemory);
- transform->MoveBy(offset);
-
- CATCH_ALL
-
- if (transform!=NULL)
- delete transform;
-
- RERAISE;
-
- ENDTRY
-
- return transform;
- }
-
- #ifdef FW_BUILD_MAC
- //------------------------------------------------------------------------------
- // ::GetPortTextStyle:
- //------------------------------------------------------------------------------
-
- void GetPortTextStyle(TextStyle& theTextStyle)
- {
- theTextStyle.tsFont = XMPASLMQDGlobals.thePort->txFont;
- theTextStyle.tsFace = XMPASLMQDGlobals.thePort->txFace;
- theTextStyle.tsSize = XMPASLMQDGlobals.thePort->txSize;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //------------------------------------------------------------------------------
- // ::SetPortTextStyle:
- //------------------------------------------------------------------------------
-
- void SetPortTextStyle(const TextStyle& theTextStyle)
- {
- ::TextFont(theTextStyle.tsFont);
- ::TextFace(theTextStyle.tsFace);
- ::TextSize(theTextStyle.tsSize);
- }
- #endif
-